﻿namespace Medicalsystem.MCP.FormDesigner.Common
{
    /// <summary>
    /// ControlItem 的摘要说明。
    /// 本对象主要用于ComboBox等的Item标记用。
    /// </summary>
    public class ControlItem<T>
    {
        public ControlItem(T obj, string text)
        {
            this.m_obj = obj;
            this.m_text = text;
        }

        private string m_text;

        public override string ToString()
        {
            return this.m_text;
        }

        public override int GetHashCode()
        {
            return 11;
        }

        public override bool Equals(object obj)
        {
            if (obj is ControlItem<T>)
            {
                return (obj as ControlItem<T>).m_obj.Equals(this.m_obj);
            }
            else
            {
                return false;
            }
        }

        public string Text
        {
            get
            {
                return this.m_text;
            }
            set
            {
                this.m_text = value;
            }
        }

        private T m_obj;

        public T Object
        {
            get
            {
                return this.m_obj;
            }
            set
            {
                this.m_obj = value;
            }
        }
    }
}